package org.apache.harmony.javax.security.auth;

import java.security.DomainCombiner;
import java.security.Principal;
import java.security.ProtectionDomain;
import java.util.Set;

public class SubjectDomainCombiner
  implements DomainCombiner
{
  private Subject subject;
  private static final AuthPermission _GET = new AuthPermission("getSubjectFromDomainCombiner");

  public SubjectDomainCombiner(Subject paramSubject)
  {
    if (paramSubject == null)
      throw new NullPointerException();
    this.subject = paramSubject;
  }

  public Subject getSubject()
  {
    SecurityManager localSecurityManager = System.getSecurityManager();
    if (localSecurityManager != null)
      localSecurityManager.checkPermission(_GET);
    return this.subject;
  }

  public ProtectionDomain[] combine(ProtectionDomain[] paramArrayOfProtectionDomain1, ProtectionDomain[] paramArrayOfProtectionDomain2)
  {
    int i = 0;
    if (paramArrayOfProtectionDomain1 != null)
      i += paramArrayOfProtectionDomain1.length;
    if (paramArrayOfProtectionDomain2 != null)
      i += paramArrayOfProtectionDomain2.length;
    if (i == 0)
      return null;
    ProtectionDomain[] arrayOfProtectionDomain = new ProtectionDomain[i];
    int j = 0;
    if (paramArrayOfProtectionDomain1 != null)
    {
      Set localSet = this.subject.getPrincipals();
      Principal[] arrayOfPrincipal = (Principal[])localSet.toArray(new Principal[localSet.size()]);
      for (j = 0; j < paramArrayOfProtectionDomain1.length; j++)
        if (paramArrayOfProtectionDomain1[j] != null)
        {
          ProtectionDomain localProtectionDomain = new ProtectionDomain(paramArrayOfProtectionDomain1[j].getCodeSource(), paramArrayOfProtectionDomain1[j].getPermissions(), paramArrayOfProtectionDomain1[j].getClassLoader(), arrayOfPrincipal);
          arrayOfProtectionDomain[j] = localProtectionDomain;
        }
    }
    if (paramArrayOfProtectionDomain2 != null)
      System.arraycopy(paramArrayOfProtectionDomain2, 0, arrayOfProtectionDomain, j, paramArrayOfProtectionDomain2.length);
    return arrayOfProtectionDomain;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.apache.harmony.javax.security.auth.SubjectDomainCombiner
 * JD-Core Version:    0.6.1
 */